/**
 * @file
 * @author  Tsin Smith <tsin.creator@gmail.com>
 *
 * @section DESCRIPTION
 *
 * Interface for display.
 *
 */

#ifndef __TSIN_DISPLAY_GLDISPLAY_HPP__
#define __TSIN_DISPLAY_GLDISPLAY_HPP__

#include <tsin/display/common.hpp>

#include <tsin/display/Display.hpp>
#include <tsin/util/Resolution.hpp>

#include <map>

struct SDL_Surface;

namespace tsin {

        class Config;
        class Logger;
        class GameViewport;
        class Image;
        class GLImage;
        class DecoratedImage;

        typedef std::map<const char *, GLImage *> ImageMap;

        /**
         * @class GLDisplay
         * @ingroup display
         * @brief Implementation of Display using OpenGL.
         */
        class DISPLAY_DLLEXPORT GLDisplay : public Display
        {
        public:
                GLDisplay();
                virtual ~GLDisplay();

                virtual bool init(const Config &config);

                virtual bool setWindowName(const char *name);
                virtual bool setWindowIcon(const char *name);
                virtual bool clear();
                virtual bool update();

                virtual void useOverallFrame();
                virtual void useViewportFrame(GameViewport &viewport);

                virtual Image *openImage(const char *path, StandardResolution res);
                virtual void blitImage(Image &image, float x, float y, 
                                       float width, float height,
                                       float angle, float z);
                virtual void blitImage(DecoratedImage &image, float x, float y,
                                       float width, float height, float angle, float z, int align);

        private:
                StandardResolution resolution;
                float xLeft, xRight, yBottom, yTop;

                const Config *config;
                struct SDL_Surface *icon;
                GameViewport *viewport;
                bool glSetup();
                void setupBlendStyle(BlendStyle style);
        };

}

#endif /* __TSIN_DISPLAY_GLDISPLAY_HPP__ */
